<template>
	<view class="formpanel">
		<form @submit="formSubmit">
			<view class="group border-tb">当事人信息</view>
			<view class="cu-form-group border-b">
				<view class="title">被处罚人</view>
				<view class="text"><input name="RealName" placeholder="请输入被处罚人姓名" placeholder-class="gray" :value="Info.RealName"></input></view>
			</view>
			<view class="cu-form-group border-b">
				<view class="title">联系电话</view>
				<view class="text"><input name="Mobile" type="number" placeholder="请输入被处罚人联系电话" placeholder-class="gray" :value="Info.Mobile"></input></view>
			</view>
			<view class="group">当事人签字 <text class="resign" v-if="Info.State==0 && ID>0 && Info.SignName!=''" @click="SignName">重新签字</text></view>
			<view class="signlist">
				<view class="signname" v-if="Info.State==0 && Info.SignName==''" @click="SignName">点此签字</view>
				<image v-else :src="Tools.GetImg(Info.SignName,500)" mode="aspectFit" @click="SignName"></image>
			</view>
			<view class="btn">
				<button class="publishs" form-type="submit" v-if="Info.State==0">确定处罚</button>
			</view>
		</form>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				Info:{ID:0}
			};
		},
		onLoad(options) {
			//监听生成签字的图片地址
			uni.$on('q-sign',path =>{
				this.Util.Loading("请稍候...");
				this.Util.OneUpload(path,"upload_file_signname",img=>{
					this.Info.SignName=img;
					this.SaveSignName(img);
				});
			});
			this.ID=options.ID;
			this.Find_ParkInfo();
		},
		onUnload() {
			uni.$off('q-sign') //移除监听事件
		},
		methods:{
			Find_ParkInfo(){
				var data = {};
				data.ID=this.ID;
				data.Act="Find_ParkInfo";
				this.Util.Loading("加载中...");
				this.Util.Post(data, json=>{
					this.Util.HideLoading();
					uni.stopPullDownRefresh();
					uni.hideNavigationBarLoading();
					this.Info = json.Data.Info;
				});
			},
			SignName(){
				if(this.Info.State==0){
					uni.navigateTo({
						url:'/uni_modules/q-sign/q-sign'
					})
				}
			},
			SaveSignName(SignName){
				var data={};
				data.Act="Save_ParkSignName";
				data.ID=this.ID;
				data.SignName=SignName;
				this.Util.Post(data, json=>{
					this.Util.HideLoading();
					if(json.State){
						this.Util.Toast(json.Msg);
					}else{
						this.Util.Alert(json.Msg);
					}
				});
			},
			formSubmit(e){
				var data = e.detail.value;
				data.Act="ChuFa_Park";
				data.ID=this.ID;
				this.Util.Confirm("您确定要处罚吗？",()=>{
					this.Util.Loading("请稍候...");
					this.Util.Post(data, json=>{
						this.Util.HideLoading();
						if(json.State){
							this.Util.Toast(json.Msg, obj=>{
								uni.$emit("ChuFaSuccess","");
								uni.navigateBack({
									delta:1
								})
							});
						}else{
							this.Util.Alert(json.Msg);
						}
					});
				});
			}
		}
	}
</script>

<style lang="scss">
	.group{width:100%; height:80rpx; line-height: 80rpx; padding-left:30rpx; font-size:32rpx; margin-top:25rpx; color:#3d7dfd; background-color: #ffffff;
		.number{color:#000000; padding-right:30rpx; float:right;}
		.resign{color:#00c1a8; padding-right:30rpx; float:right;}
	}
	.signlist{width:100%; height:auto; position: relative; overflow:hidden; padding-bottom: 20rpx; padding-left:10rpx; background-color: #ffffff;
		image{width:500rpx; height:200rpx;}
	}
	.signname{width:100%; height:150rpx; line-height: 100rpx; border:0rpx; border-radius: 0rpx; text-align: center; color:#a8a8a8; font-size:40rpx;}
</style>
